<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <title>WASM memory export example</title>
  </head>

  <body>
    <script>
      WebAssembly.instantiateStreaming(fetch("memory-export.wasm")).then(
        (object) => {
          const values = new DataView(object.instance.exports.memory.buffer);
          let sum = 0;
          // views only the first ten elements of the Wasm memory
          for (let i = 0 ; i < 10; i++) {
            sum += values.getUint32(i * 4, true);
          }
          console.log(sum);
        }
      );
    </script>
  </body>
</html>
